package com.timetable;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.easylib.base.BaseActivity;
import com.easylib.utils.ToastUtils;
import com.easylib.utils.VibratorUtils;

import butterknife.Bind;
import butterknife.OnClick;
import cn.iwgang.countdownview.CountdownView;

public class TomatoActivity extends BaseActivity {

    @Bind(R.id.countdownview)
    CountdownView countdownview;
    @Bind(R.id.btn)
    Button btn;


    @Override
    public int getContentViewId() {
        return R.layout.activity_tomato;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

    }

    @Override
    protected void initVariable() {

    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {
        countdownview.setOnCountdownEndListener(new CountdownView.OnCountdownEndListener() {
            @Override
            public void onEnd(CountdownView cv) {
                VibratorUtils.Vibrate(TomatoActivity.this,2000);
                ToastUtils.showToast("时间已到，请注意休息");
                btn.setText("开始倒计时");
                btn.setEnabled(true);
            }
        });
    }

    @OnClick(R.id.btn)
    public void onClick() {
        btn.setEnabled(false);
        btn.setText("正在倒计时");
        countdownview.start(30*1000);
    }
}
